import { Pie } from '@ant-design/charts';
import React from 'react';
import { useRequest } from '@umijs/hooks';
import { useState } from 'react';
import { getyjStatistic, getyqStatistic } from '@/services/zhirong/dataIntegration';

const EnterprisePie = ({ data }) => {
  const [pie, setPie] = useState();
  const { loading: loadingPie } = useRequest(getyqStatistic, {
    onSuccess: (res) => {
      setPie(res.data);
    },
  });
  const config = {
    appendPadding: 10,
    data: pie,
    angleField: 'value',
    colorField: 'type',
    color: ['#9254DE', '#722ED1', '#531DAB', '#B37FEB', '#D3ADF7'],
    radius: 1,
    label: false,
    width: '200px',
    interactions: [
      {
        type: 'element-active',
      },
      {
        type: 'element-selected',
      },
    ],
  };
  return pie ? <Pie {...config} style={{ height: '90%' }} loading={loadingPie} /> : null;
};

export default EnterprisePie;
